package tech.runchen.gz5055.oms.security.crypto;

import cn.hutool.crypto.SecureUtil;
import org.springframework.security.crypto.password.PasswordEncoder;

public class MD5PasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence rawPassword) {
        return SecureUtil.md5(String.valueOf(rawPassword));
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        if (SecureUtil.md5(String.valueOf(rawPassword)).equalsIgnoreCase(encodedPassword)) {
            return true;
        }
        return false;
    }
}
